package com.itheima.controller;

import com.itheima.Exception.BusinessException;
import org.apache.ibatis.builder.BuilderException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author tongchen
 * @create 2022-12-13 14:23
 */
@RestControllerAdvice
public class ExceptionSolver {
    @ExceptionHandler(BusinessException.class)
    public Result doException(BusinessException ex) {
        return new Result(ex.getCode(), null, ex.getMessage());
    }
    @ExceptionHandler(Exception.class)
    public Result doException(Exception ex){
        return new Result(666,null,"出现异常啦");
    }
}
